package com.tyl.controller;

import com.tyl.pojo.Department;
import com.tyl.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/Departments")
public class DepartmentController {
    @Autowired
    private DepartmentService departmentService;

    @ResponseBody
    @GetMapping("/queryAllDepartmentList")
    public List<Department> queryAllDepartmentList(){
        return departmentService.queryAllDepartmentList();
    }
    @ResponseBody
    @GetMapping("/queryDepartmentById")
    public Department queryDepartmentById(int Id){
        return departmentService.queryDepartmentById(Id);
    }

    @ResponseBody
    @PostMapping("/addDepartment")
    public int addDepartment(Department department){
        return departmentService.addDepartment(department);
    }

    @ResponseBody
    @PostMapping("/deleteDepartment")
    public int deleteDepartment(int Id){
        return departmentService.deleteDepartment(Id);
    }

    @ResponseBody
    @PostMapping("/updateDepartment")
    public int updateDepartment(Department department){
        return departmentService.updateDepartment(department);
    }

}
